<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
.editor table {
	display: inline;
	vertical-align: top;
}
</style>
<div class="r_location">
	<i class="r_txtico"></i> 内容管理&gt; 课时管理 &gt; 新建课时管理
</div>
<form id="add_form" action="cms/course/add"  enctype="multipart/form-data" method="post">
	<input type="hidden" name="stats" value="1">
	<ul class="all_list">
		<li><span class="all_title">课时类型：</span>
			<span>
					<select name="type" id="type" validator='{"label":"类型"}' class="ui_select">
						<option value="">请选择</option>
						<option value="1">PS基础</option>
						<option value="2">PS中级</option>
						<option value="3">PS高级</option>
						<option value="4">摄影基础</option>
						<option value="5">摄影中级</option>
						<option value="6">摄影高级</option>
						<option value="7">活动</option>
						<option value="8">讲座</option>
				</select>
			</span>
			</li>
		<li> <span class="all_title">课程（活动，讲座）名字：</span> <span> <input
				class="ui_input" id="name"
				validator='{"label":"排序","isDigit":false,"minLength":1,"maxLength":20}'
				name="name" style="width: 100px;">
		</span></li>
		<li>
			<span class="all_title">课时：</span>
			<span>
				<input class="ui_input" id="classHour" validator='{"label":"名称","isDigit":true,"minLength":1,"maxLength":50}'  name="classHour" style="width:100px;">
			</span>
		</li>
		<li>
			<span class="all_title">老师：</span>
			<span>
				<input class="ui_input" id="teacher" validator='{"label":"名称","isDigit":false,"minLength":1,"maxLength":50}'  name="teacher" style="width:100px;">
			</span>
		</li>
		<li>
				<span class="all_title">推送时间：</span> 
				<span>
					<input type="text" id="pushTime" name="pushTime" class="ui_input datepicker Wdate" dateFormat="yyyy-MM-dd HH:mm:ss" group='{"group": {"startId":"pushTime", "endId":"pushTime","showNext": true}}' option='start-auto-end' /> 
				</span>
			</li>
		<li>
				<span class="all_title">上课时间：</span> 
				<span>
					<input type="text" id="time" name="time" class="ui_input datepicker Wdate" dateFormat="yyyy-MM-dd HH:mm:ss" group='{"group": {"startId":"time", "endId":"time","showNext": true}}' option='start-auto-end' />
				</span>
			</li>
		<li class="editor"><span class="all_title">课程描述</span> <span>
				<textarea id="content" name="remark"
					class="xheditor {tools:'FontSize,FontColor,Bold,Italic,Underline,Strikethrough,Fullscreen,Align,About',skin:'default',height:'300'}"
					rows="8" cols="80" style="width: 70%">
				</textarea> <span id="contentError"></span>
		</span></li>
		<li><span class="all_title"></span> <span> <input
				type="button" id="viewBtn" value="预览" onclick="preView()"
				class="btn_blue m-r15"> <input type="button"
				id="addBtn" value="提交" class="btn_blue m-r15 submitBtn">
		</span></li>
	</ul>
</form>
<script type="text/javascript">
    var myDialog;
 
	$.datepicker();
	$(function() {
		$('#content').xheditor();
		$('#reset_button').click(function() {
			$('#content').val('');
		});

		$("#aboutType").change(
				function() {
					var aboutType = $("#aboutType").val();
					if (aboutType == "1") {
						$(document).find("div[data-id='jianjie']").css(
								"display", "");
					} else {
						$(document).find("div[data-id='jianjie']").css(
								"display", "none");
					}
				});
		$("#aboutType").change();

		$("#add_form").validator({}, {
			callback : function(data) {
				if (!$('#type').val()) {
					alert("类型不能为空");
					return false;
				}
				if (!$('#name').val()) {
					alert("名字不能为空");
					return false;
				}
				if (!$('#classHour').val()) {
					alert("课时不能为空");
					return false;
				}
				if (!$('#teacher').val()) {
					alert("老师不能为空");
					return false;
				}
				if (!$('#pushTime').val()) {
					alert("推送时间不能为空");
					return false;
				}
				if (!$('#time').val()) {
					alert("上课时间不能为空");
					return false;
				}
				
				if (!$('#content').val()) {
					$('#contentError').html('内容不能为空!').addClass('frame_error');
					return false;
				} else {
					$('#contentError').html('').removeClass('frame_error');
				}
				$("#add_form").ajaxSubmit(function(data) {
					if (data.success == 'succeed') {
						art.dialog({
							icon : data.success,
							content : data.message,
							lock : true
						}).time(1);
						to_page('/cms/course/view/page');
					} else {
						art.dialog({
							icon : data.success,
							content : data.message,
							lock : true
						});
					}
				});
			}
		});

	});
</script>